'''
Created on Aug 13, 2012

@author: petrina
'''
from indicatorset import  Indicatorset

# import the indicators
from buffer_index import Buffer_index
from planning_time import Planning_time
from planning_speed import Planning_speed
from buffer_time import Buffer_time
from buffer_speed import Buffer_speed
from buffer_speed_index import Buffer_speed_index
from variation_speeds import Variation_speeds
from planning_time_index import Planning_time_index
from planning_speed_index import Planning_speed_index
from mean_squared_error import Mean_squared_error
from mean_error import Mean_error
from correlation_coefficient import Correlation_coefficient
from total_mean_error import Total_mean_error
from total_mean_squared_error import Total_mean_squared_error
from total_correlation_coefficient import Total_correlation_coefficient
from stddev_absdiff import Stddev_absdiff
from stddev_estimated import Stddev_estimated
from stddev_observed import Stddev_observed

import logging


class Link_indicatorset(Indicatorset):
    '''
    Set of indicators, which may be applied to record_lists containing agg_record-objects from FLEET.
    
    It uses a reference to the link, so that the indicators can be set up with data from the link, such
    as aggregated records, timeseries, reference data, length of the link and free flow information.
    If the indiconf is set None all the indicators will be calculated.
    '''


    def __init__(self, indiconf = None, link = None):
        '''
        @param indiconf: the Indicator-configuration is a list containing the indicators-abbreviations or None (= all indicators, default) 
        @param link: link for filling indicators
        '''
        
        Indicatorset.__init__(self, indiconf)
        
        # reference to record_list-object
        self._link = link
        
        self._name=self._link.exportname
        
        logging.debug("Link_indicatorset: created Link_indicatorset")    

        
    #----------------------public methods of the class-------------------------
        
    
    def build_all_indis(self):
        '''
        Add all possible indicators to the set.
        
        The list will contain following indicators:
            - Buffer (Time) Index
            - Planning Time
            - Planning Speed
            - Buffer Time
            - Buffer Speed
            - Buffer Speed Index
            - Variation of Speeds
            - Planning Time Index
            - Planning Speed Index
            - Mean Squared Error (MSE)
            - Mean Error (ME)
            - Correlation Coefficient
            - Total Mean Error
            - Total Squared Mean Error
            - Total Correlation Coefficient
            - Standard deviation difference
            - Standard deviation of estimated values
            - Standard deviation of observed values
        '''
                        
        # add indicators to private set
        self._indiset.add(Buffer_index(self._link))
        self._indiset.add(Planning_time(self._link))
        self._indiset.add(Planning_speed(self._link))
        self._indiset.add(Buffer_time(self._link))
        self._indiset.add(Buffer_speed(self._link))
        self._indiset.add(Buffer_speed_index(self._link))
        self._indiset.add(Variation_speeds(self._link))
        self._indiset.add(Planning_time_index(self._link))
        self._indiset.add(Planning_speed_index(self._link))
        self._indiset.add(Mean_squared_error(self._link))
        self._indiset.add(Mean_error(self._link))
        self._indiset.add(Correlation_coefficient(self._link))
        self._indiset.add(Total_mean_error(self._link))
        self._indiset.add(Total_mean_squared_error(self._link))
        self._indiset.add(Total_correlation_coefficient(self._link))
        self._indiset.add(Stddev_absdiff(self._link))
        self._indiset.add(Stddev_observed(self._link))
        self._indiset.add(Stddev_estimated(self._link))
                
        
        logging.info("Link_indicatorset: added all possible indicators")